
#ifndef _TTG_MATH_ALGEBRA_
#define _TTG_MATH_ALGEBRA_
#include "Common/Definitions.h"

#include "vec3x.h"

namespace ttg
{
	namespace math
	{
		//Represents equation a * x * x + b * x + c = 0;
		class QuadraticEquation
		{
			private:
				float coeff[3];
			public:
				//Creates qudratic equation with given coefficients.
				inline QuadraticEquation(float a, float b, float c)
						{ coeff[0] = a; coeff[1] = b; coeff[2] = c; }
				//Returns n-th coefficient.
				inline float &operator[] (const int n)
						{ return coeff[n]; }
				inline const float &operator[] (const int n) const
						{ return coeff[n]; }
				inline float A() const
						{ return coeff[0]; }
				inline float B() const
						{ return coeff[1]; }
				inline float C() const
						{ return coeff[2]; }
				//Solves given equation. Returns count of solutions. x1 <= x2.
				int solve(float &x1, float &x2);
		};
	}
}

#endif
